# coding:utf-8
from dataclasses import dataclass
import re
import os
import sys
import json
from PyQt6.QtCore import Qt, QUrl
from PyQt6.QtWidgets import QWidget, QHBoxLayout, QSpacerItem, QSizePolicy, QCompleter
from qfluentwidgets import (
    SearchLineEdit,
    PushButton,
)
from qframelesswindow.webengine import FramelessWebEngineView


from .base_gallery_view import GalleryInterface
from .common.translator import Translator
from .base_gallery_view import GalleryInterface
from service.stock_service import getAllStockListSample


@dataclass
class ShowViewConfig:

    # 展示顶部搜索栏 ：
    show_top: bool


class BaseInfoTemplateView(GalleryInterface):
    """Scroll interface"""

    def __init__(self, objectName, parent=None):
        t = Translator()
        super().__init__(
            title=t.scroll, subtitle="qfluentwidgets.components.widgets", parent=parent
        )
        self.setObjectName(objectName)
        self.searchKey = ""

        # 添加底部操作栏
        self.mainView = MainTemplate(self)
        self.vBoxLayout.addWidget(self.mainView)


class MainTemplate(QWidget):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.hBoxLayout = QHBoxLayout()

        self.__initWidget()

    def __initWidget(self):

        # 默认中间模板是水平结构
        self.setLayout(self.hBoxLayout)

    def addMainWidget(self, itemWidget: QWidget):
        self.hBoxLayout.addWidget(itemWidget)
